// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyStatisticalTrendsAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>

// ****************************************************************************
// Module: PyStatisticalTrendsAttributes
//
// Purpose:
//   This class contains attributes for the StatisticalTrends operator.
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a StatisticalTrendsAttributes.
//
struct StatisticalTrendsAttributesObject
{
    PyObject_HEAD
    StatisticalTrendsAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewStatisticalTrendsAttributes(int);
std::string
PyStatisticalTrendsAttributes_ToString(const StatisticalTrendsAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    snprintf(tmpStr, 1000, "%sstartIndex = %d\n", prefix, atts->GetStartIndex());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sstopIndex = %d\n", prefix, atts->GetStopIndex());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sstride = %d\n", prefix, atts->GetStride());
    str += tmpStr;
    const char *startTrendType_names = "Absolute, Relative";
    switch (atts->GetStartTrendType())
    {
      case StatisticalTrendsAttributes::Absolute:
          snprintf(tmpStr, 1000, "%sstartTrendType = %sAbsolute  # %s\n", prefix, prefix, startTrendType_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::Relative:
          snprintf(tmpStr, 1000, "%sstartTrendType = %sRelative  # %s\n", prefix, prefix, startTrendType_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const char *stopTrendType_names = "Absolute, Relative";
    switch (atts->GetStopTrendType())
    {
      case StatisticalTrendsAttributes::Absolute:
          snprintf(tmpStr, 1000, "%sstopTrendType = %sAbsolute  # %s\n", prefix, prefix, stopTrendType_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::Relative:
          snprintf(tmpStr, 1000, "%sstopTrendType = %sRelative  # %s\n", prefix, prefix, stopTrendType_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const char *statisticType_names = "Sum, Mean, Variance, StandardDeviation, Slope, "
        "Residuals";
    switch (atts->GetStatisticType())
    {
      case StatisticalTrendsAttributes::Sum:
          snprintf(tmpStr, 1000, "%sstatisticType = %sSum  # %s\n", prefix, prefix, statisticType_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::Mean:
          snprintf(tmpStr, 1000, "%sstatisticType = %sMean  # %s\n", prefix, prefix, statisticType_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::Variance:
          snprintf(tmpStr, 1000, "%sstatisticType = %sVariance  # %s\n", prefix, prefix, statisticType_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::StandardDeviation:
          snprintf(tmpStr, 1000, "%sstatisticType = %sStandardDeviation  # %s\n", prefix, prefix, statisticType_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::Slope:
          snprintf(tmpStr, 1000, "%sstatisticType = %sSlope  # %s\n", prefix, prefix, statisticType_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::Residuals:
          snprintf(tmpStr, 1000, "%sstatisticType = %sResiduals  # %s\n", prefix, prefix, statisticType_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const char *trendAxis_names = "Step, Time, Cycle";
    switch (atts->GetTrendAxis())
    {
      case StatisticalTrendsAttributes::Step:
          snprintf(tmpStr, 1000, "%strendAxis = %sStep  # %s\n", prefix, prefix, trendAxis_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::Time:
          snprintf(tmpStr, 1000, "%strendAxis = %sTime  # %s\n", prefix, prefix, trendAxis_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::Cycle:
          snprintf(tmpStr, 1000, "%strendAxis = %sCycle  # %s\n", prefix, prefix, trendAxis_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const char *variableSource_names = "Default, OperatorExpression";
    switch (atts->GetVariableSource())
    {
      case StatisticalTrendsAttributes::Default:
          snprintf(tmpStr, 1000, "%svariableSource = %sDefault  # %s\n", prefix, prefix, variableSource_names);
          str += tmpStr;
          break;
      case StatisticalTrendsAttributes::OperatorExpression:
          snprintf(tmpStr, 1000, "%svariableSource = %sOperatorExpression  # %s\n", prefix, prefix, variableSource_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    return str;
}

static PyObject *
StatisticalTrendsAttributes_Notify(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_SetStartIndex(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the startIndex in the object.
    obj->data->SetStartIndex(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_GetStartIndex(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetStartIndex()));
    return retval;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_SetStopIndex(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the stopIndex in the object.
    obj->data->SetStopIndex(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_GetStopIndex(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetStopIndex()));
    return retval;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_SetStride(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the stride in the object.
    obj->data->SetStride(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_GetStride(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetStride()));
    return retval;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_SetStartTrendType(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid startTrendType value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Absolute";
        ss << ", Relative";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the startTrendType in the object.
    obj->data->SetStartTrendType(StatisticalTrendsAttributes::TrendTypeEnum(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_GetStartTrendType(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetStartTrendType()));
    return retval;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_SetStopTrendType(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid stopTrendType value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Absolute";
        ss << ", Relative";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the stopTrendType in the object.
    obj->data->SetStopTrendType(StatisticalTrendsAttributes::TrendTypeEnum(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_GetStopTrendType(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetStopTrendType()));
    return retval;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_SetStatisticType(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 6)
    {
        std::stringstream ss;
        ss << "An invalid statisticType value was given." << std::endl;
        ss << "Valid values are in the range [0,5]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Sum";
        ss << ", Mean";
        ss << ", Variance";
        ss << ", StandardDeviation";
        ss << ", Slope";
        ss << ", Residuals";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the statisticType in the object.
    obj->data->SetStatisticType(StatisticalTrendsAttributes::StatisticTypeEnum(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_GetStatisticType(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetStatisticType()));
    return retval;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_SetTrendAxis(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 3)
    {
        std::stringstream ss;
        ss << "An invalid trendAxis value was given." << std::endl;
        ss << "Valid values are in the range [0,2]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Step";
        ss << ", Time";
        ss << ", Cycle";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the trendAxis in the object.
    obj->data->SetTrendAxis(StatisticalTrendsAttributes::TrendAxisEnum(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_GetTrendAxis(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetTrendAxis()));
    return retval;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_SetVariableSource(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid variableSource value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Default";
        ss << ", OperatorExpression";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the variableSource in the object.
    obj->data->SetVariableSource(StatisticalTrendsAttributes::VariableSourceEnum(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
StatisticalTrendsAttributes_GetVariableSource(PyObject *self, PyObject *args)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetVariableSource()));
    return retval;
}



PyMethodDef PyStatisticalTrendsAttributes_methods[STATISTICALTRENDSATTRIBUTES_NMETH] = {
    {"Notify", StatisticalTrendsAttributes_Notify, METH_VARARGS},
    {"SetStartIndex", StatisticalTrendsAttributes_SetStartIndex, METH_VARARGS},
    {"GetStartIndex", StatisticalTrendsAttributes_GetStartIndex, METH_VARARGS},
    {"SetStopIndex", StatisticalTrendsAttributes_SetStopIndex, METH_VARARGS},
    {"GetStopIndex", StatisticalTrendsAttributes_GetStopIndex, METH_VARARGS},
    {"SetStride", StatisticalTrendsAttributes_SetStride, METH_VARARGS},
    {"GetStride", StatisticalTrendsAttributes_GetStride, METH_VARARGS},
    {"SetStartTrendType", StatisticalTrendsAttributes_SetStartTrendType, METH_VARARGS},
    {"GetStartTrendType", StatisticalTrendsAttributes_GetStartTrendType, METH_VARARGS},
    {"SetStopTrendType", StatisticalTrendsAttributes_SetStopTrendType, METH_VARARGS},
    {"GetStopTrendType", StatisticalTrendsAttributes_GetStopTrendType, METH_VARARGS},
    {"SetStatisticType", StatisticalTrendsAttributes_SetStatisticType, METH_VARARGS},
    {"GetStatisticType", StatisticalTrendsAttributes_GetStatisticType, METH_VARARGS},
    {"SetTrendAxis", StatisticalTrendsAttributes_SetTrendAxis, METH_VARARGS},
    {"GetTrendAxis", StatisticalTrendsAttributes_GetTrendAxis, METH_VARARGS},
    {"SetVariableSource", StatisticalTrendsAttributes_SetVariableSource, METH_VARARGS},
    {"GetVariableSource", StatisticalTrendsAttributes_GetVariableSource, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
StatisticalTrendsAttributes_dealloc(PyObject *v)
{
   StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *StatisticalTrendsAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyStatisticalTrendsAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "startIndex") == 0)
        return StatisticalTrendsAttributes_GetStartIndex(self, NULL);
    if(strcmp(name, "stopIndex") == 0)
        return StatisticalTrendsAttributes_GetStopIndex(self, NULL);
    if(strcmp(name, "stride") == 0)
        return StatisticalTrendsAttributes_GetStride(self, NULL);
    if(strcmp(name, "startTrendType") == 0)
        return StatisticalTrendsAttributes_GetStartTrendType(self, NULL);
    if(strcmp(name, "Absolute") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Absolute));
    if(strcmp(name, "Relative") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Relative));

    if(strcmp(name, "stopTrendType") == 0)
        return StatisticalTrendsAttributes_GetStopTrendType(self, NULL);
    if(strcmp(name, "Absolute") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Absolute));
    if(strcmp(name, "Relative") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Relative));

    if(strcmp(name, "statisticType") == 0)
        return StatisticalTrendsAttributes_GetStatisticType(self, NULL);
    if(strcmp(name, "Sum") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Sum));
    if(strcmp(name, "Mean") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Mean));
    if(strcmp(name, "Variance") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Variance));
    if(strcmp(name, "StandardDeviation") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::StandardDeviation));
    if(strcmp(name, "Slope") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Slope));
    if(strcmp(name, "Residuals") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Residuals));

    if(strcmp(name, "trendAxis") == 0)
        return StatisticalTrendsAttributes_GetTrendAxis(self, NULL);
    if(strcmp(name, "Step") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Step));
    if(strcmp(name, "Time") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Time));
    if(strcmp(name, "Cycle") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Cycle));

    if(strcmp(name, "variableSource") == 0)
        return StatisticalTrendsAttributes_GetVariableSource(self, NULL);
    if(strcmp(name, "Default") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::Default));
    if(strcmp(name, "OperatorExpression") == 0)
        return PyInt_FromLong(long(StatisticalTrendsAttributes::OperatorExpression));



    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyStatisticalTrendsAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyStatisticalTrendsAttributes_methods[i].ml_name),
                PyString_FromString(PyStatisticalTrendsAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyStatisticalTrendsAttributes_methods, self, name);
}

int
PyStatisticalTrendsAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "startIndex") == 0)
        obj = StatisticalTrendsAttributes_SetStartIndex(self, args);
    else if(strcmp(name, "stopIndex") == 0)
        obj = StatisticalTrendsAttributes_SetStopIndex(self, args);
    else if(strcmp(name, "stride") == 0)
        obj = StatisticalTrendsAttributes_SetStride(self, args);
    else if(strcmp(name, "startTrendType") == 0)
        obj = StatisticalTrendsAttributes_SetStartTrendType(self, args);
    else if(strcmp(name, "stopTrendType") == 0)
        obj = StatisticalTrendsAttributes_SetStopTrendType(self, args);
    else if(strcmp(name, "statisticType") == 0)
        obj = StatisticalTrendsAttributes_SetStatisticType(self, args);
    else if(strcmp(name, "trendAxis") == 0)
        obj = StatisticalTrendsAttributes_SetTrendAxis(self, args);
    else if(strcmp(name, "variableSource") == 0)
        obj = StatisticalTrendsAttributes_SetVariableSource(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
StatisticalTrendsAttributes_print(PyObject *v, FILE *fp, int flags)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)v;
    fprintf(fp, "%s", PyStatisticalTrendsAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
StatisticalTrendsAttributes_str(PyObject *v)
{
    StatisticalTrendsAttributesObject *obj = (StatisticalTrendsAttributesObject *)v;
    return PyString_FromString(PyStatisticalTrendsAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *StatisticalTrendsAttributes_Purpose = "This class contains attributes for the StatisticalTrends operator.";
#else
static char *StatisticalTrendsAttributes_Purpose = "This class contains attributes for the StatisticalTrends operator.";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(StatisticalTrendsAttributesType,         \
                  "StatisticalTrendsAttributes",           \
                  StatisticalTrendsAttributesObject,       \
                  StatisticalTrendsAttributes_dealloc,     \
                  StatisticalTrendsAttributes_print,       \
                  PyStatisticalTrendsAttributes_getattr,   \
                  PyStatisticalTrendsAttributes_setattr,   \
                  StatisticalTrendsAttributes_str,         \
                  StatisticalTrendsAttributes_Purpose,     \
                  StatisticalTrendsAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
StatisticalTrendsAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &StatisticalTrendsAttributesType
         || Py_TYPE(other) != &StatisticalTrendsAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    StatisticalTrendsAttributes *a = ((StatisticalTrendsAttributesObject *)self)->data;
    StatisticalTrendsAttributes *b = ((StatisticalTrendsAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static StatisticalTrendsAttributes *defaultAtts = 0;
static StatisticalTrendsAttributes *currentAtts = 0;

static PyObject *
NewStatisticalTrendsAttributes(int useCurrent)
{
    StatisticalTrendsAttributesObject *newObject;
    newObject = PyObject_NEW(StatisticalTrendsAttributesObject, &StatisticalTrendsAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new StatisticalTrendsAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new StatisticalTrendsAttributes(*defaultAtts);
    else
        newObject->data = new StatisticalTrendsAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapStatisticalTrendsAttributes(const StatisticalTrendsAttributes *attr)
{
    StatisticalTrendsAttributesObject *newObject;
    newObject = PyObject_NEW(StatisticalTrendsAttributesObject, &StatisticalTrendsAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (StatisticalTrendsAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
StatisticalTrendsAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewStatisticalTrendsAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef StatisticalTrendsAttributesMethods[] = {
    {"StatisticalTrendsAttributes", StatisticalTrendsAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *StatisticalTrendsAttributesObserver = 0;

std::string
PyStatisticalTrendsAttributes_GetLogString()
{
    std::string s("StatisticalTrendsAtts = StatisticalTrendsAttributes()\n");
    if(currentAtts != 0)
        s += PyStatisticalTrendsAttributes_ToString(currentAtts, "StatisticalTrendsAtts.", true);
    return s;
}

static void
PyStatisticalTrendsAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("StatisticalTrendsAtts = StatisticalTrendsAttributes()\n");
        s += PyStatisticalTrendsAttributes_ToString(currentAtts, "StatisticalTrendsAtts.", true);
        cb(s);
    }
}

void
PyStatisticalTrendsAttributes_StartUp(StatisticalTrendsAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyStatisticalTrendsAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(StatisticalTrendsAttributesObserver == 0)
    {
        StatisticalTrendsAttributesObserver = new ObserverToCallback(subj,
            PyStatisticalTrendsAttributes_CallLogRoutine, (void *)data);
    }

}

void
PyStatisticalTrendsAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete StatisticalTrendsAttributesObserver;
    StatisticalTrendsAttributesObserver = 0;
}

PyMethodDef *
PyStatisticalTrendsAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return StatisticalTrendsAttributesMethods;
}

bool
PyStatisticalTrendsAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &StatisticalTrendsAttributesType);
}

StatisticalTrendsAttributes *
PyStatisticalTrendsAttributes_FromPyObject(PyObject *obj)
{
    StatisticalTrendsAttributesObject *obj2 = (StatisticalTrendsAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PyStatisticalTrendsAttributes_New()
{
    return NewStatisticalTrendsAttributes(0);
}

PyObject *
PyStatisticalTrendsAttributes_Wrap(const StatisticalTrendsAttributes *attr)
{
    return WrapStatisticalTrendsAttributes(attr);
}

void
PyStatisticalTrendsAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    StatisticalTrendsAttributesObject *obj2 = (StatisticalTrendsAttributesObject *)obj;
    obj2->parent = parent;
}

void
PyStatisticalTrendsAttributes_SetDefaults(const StatisticalTrendsAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new StatisticalTrendsAttributes(*atts);
}

